package tests;

import static org.junit.Assert.assertTrue;
import gestioneDatabase.Post.AllPostsRetriever;
import gestioneDatabase.Post.PostsManager;
import gestioneDatabase.Post.ResponsesManager;

import java.util.ArrayList;

import models.Post;
import models.User;

import org.junit.Before;
import org.junit.Test;

public class TestResponsesManager {

	ResponsesManager responsesManager = ResponsesManager.getManager();
	PostsManager postsManager = PostsManager.getManager();
	AllPostsRetriever postsRetriever = null;
	Post post = null;
	Post testResponse = null;

	
	@Before
	public void createResponse() {
		post = new Post(new User("User"));
		post.setId(300);
		post.setTitle("Title");
		post.setContent("Content");
		postsManager.insertPost(post.getAuthor(), post.getTitle(),
				post.getContent(), "Mint");
		testResponse = new Post(new User("Responder"));
		testResponse.setContent("Response");	
	}

	@Test
	public void testGetAllResponses() {
		ArrayList<Post> testResults = postsManager.getAllPostsList();
		postsRetriever = new AllPostsRetriever();
		ArrayList<Post> testPosts = postsRetriever.getPosts();
		assertTrue(testResults.size()==testPosts.size());
	}
	
	@Test
	public void testFillSingleResponse() {
		Post fillResponse = responsesManager.fillSingleResponse("New Author",
				"New Content");
		assertTrue((fillResponse.getAuthor().getFullName().equals("New Author"))
				&& (fillResponse.getContent().equals("New Content")));
	}
	


}
